using System;

namespace Gueei.Gallery.Web.RequestModels
{
	public class PagingQueryModelBase
	{
		private int _itemsPerPage = 30;
		private int _page = 1;

		public int Page
		{
			get { return _page; }
			set
			{
				_page = value > 1 ? value : 1;
			}
		}

		public int StartItem
		{
			get { return (Page - 1) * ItemsPerPage; }
			set
			{
				_page = (int)Math.Ceiling((float)(value + 1) / (float)ItemsPerPage);
			}
		}

		public int ItemsPerPage
		{
			get
			{ return _itemsPerPage; }
			set { _itemsPerPage = value > 5 ? value : 5; }
		}
	}
}